#= 信号头尾平滑 (或许能减少炸扬声器的情况？)
 @time: 2024/7/15 15:12
 @author: Eric Tian
=#

# 内置的 smooth_function
reLU(x) = x >= 0 ? x : 0.0

# 平滑的采样点数
span = 200

smooth_front(data, smooth_function=reLU) = [[data[k] * smooth_function(k / span) for k in 1:span];
                                             data[span+1:end]]
smooth_end(data, smooth_function=reLU) = [data[1:end-span];
                                         [data[end+1-k] * smooth_function(k / span) for k in span:-1:1]]

smooth(data, smooth_function=reLU) = smooth_end(smooth_front(data, smooth_function), smooth_function)
